import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutterroom/pages/home/tab_search/dataList.dart';
import 'package:flutterroom/widgets/room_list_widget.dart';

class MyRoomSetList extends StatefulWidget {
  @override
  _MyRoomSetListState createState() => _MyRoomSetListState();
}

class _MyRoomSetListState extends State<MyRoomSetList> {
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 2,
      initialIndex: 0,
      child: Scaffold(
        floatingActionButton: GestureDetector(
          onTap: () {
            Navigator.of(context).pushNamed("roomAdd");
          },
          child: Container(
            padding: EdgeInsets.only(left: 10, right: 10, bottom: 6),
            width: ScreenUtil().setWidth(750) - 30,
            height: 44,
            decoration: BoxDecoration(
                color: Colors.green, borderRadius: BorderRadius.circular(5)),
            child: Center(
                child: Text(
              "发布房源",
              style: TextStyle(
                  color: Colors.white,
                  fontSize: 16,
                  fontWeight: FontWeight.w600),
            )),
          ),
        ),
        appBar: AppBar(
          title: Text("房屋管理"),
          bottom: TabBar(tabs: <Widget>[
            Tab(
              child: Text("空置"),
            ),
            Tab(
              child: Text("已租"),
            )
          ]),
        ),
        body: TabBarView(
          children: <Widget>[
            ListView(
              children:
                  dataList.map((item) => RoomListItemWidget(item)).toList(),
            ),
            ListView(
              children:
                  dataList.map((item) => RoomListItemWidget(item)).toList(),
            ),
          ],
        ),
      ),
    );
  }
}
